package br.ufg.inf.espweb.sgca.model;

import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ForeignKey;

/**
 *
 * @author diCastro
 */
@Entity
public class Disciplina extends Entidade{
    @Getter
    @Setter
    private Long codigo;
    @Getter
    @Setter
    private String nome;
    @Getter
    @Setter
    @ManyToOne
    @ForeignKey(name = "fk_disciplina_has_curso")
    private Curso curso;
    @Getter
    @Setter
    private BigDecimal cargaHorariaTeoria;
    @Getter
    @Setter
    private BigDecimal cargaHorariaPratica;
    @Getter
    @Setter
    @Column(length = 5000)
    private String ementa;
    
    public BigDecimal getCargaHorariaTotal(){
        if(cargaHorariaPratica == null)
            cargaHorariaPratica = BigDecimal.ZERO;
        if(cargaHorariaTeoria == null)
            cargaHorariaTeoria = BigDecimal.ZERO;
        
        return cargaHorariaPratica.add(cargaHorariaTeoria);
    }
}
